<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>

        // new 干了什么
        //   创建了一个对象
        //   this指向了这个对象
        //   返回了这个对象

        function dog(name , type) {
            // console.log(this);
            // const obj = {}
            // obj.name = name ;
            // obj.type = type ;
            this.name = name ;
            this.type = type ;
            this.say = function(){
                console.log('汪');
            }
            // return obj ;
        }

        const g = new dog('小黑' , '柯基') ;
        const g2 = new dog('小白' , '柯基') ;
        console.log(g);

        console.log(g instanceof dog);   // true

        console.log(g.say === g2.say);   // false    方法没有共享

    </script>
    
</body>
</html>